import Vue from 'vue'
import VueRouter from "vue-router";

import HomePage from '@/views/HomePage.vue'
import FunctionPage from "@/views/FunctionPage.vue";

import loginModule from '../components/LoginModule.vue';
import registerModule from "@/components/RegisterModule.vue";

import TrainPage from "@/views/TrainPage.vue";
import ExaminePage from "@/views/ExaminePage.vue"

import random_mode from '@/components/FunctionModulePage/TrainModel/training_mode_select/random_mode/random_mode'
import position_by_name_mode from '@/components/FunctionModulePage/TrainModel/training_mode_select/position_by_name_mode/position_by_name_mode'
import county_profile_mode from '@/components/FunctionModulePage/TrainModel/training_mode_select/county_profile_mode/county_profile_mode'
import test_questions_mode from "@/components/FunctionModulePage/TrainModel/training_mode_select/test_questions_mode/test_questions";

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomePage,
    children:[
      {
        path:'/login',
        name:'loginModule',
        component:loginModule
      },
      {
        path:'/register',
        name:'registerModule',
        component: registerModule
      }
    ]
  },
  {
    path:'/function',
    name:'functionPage',
    component: FunctionPage,
    // meta:{
    //   requireAuth:true   //需要进行登录验证
    // }
  },
  {
    path:'/train',
    name:'trainPage',
    component: TrainPage,
    children: [
      {
        path:'/random_mode',
        name:'random_mode_page',
        component: random_mode
      },
      {
        path:'/position_by_name_mode',
        name:'position_by_name_mode_page',
        component: position_by_name_mode
      },
        {
        path:'/county_profile_mode',
        name:'county_profile_mode_page',
        component: county_profile_mode
      },
        {
        path:'/test_questions_mode',
        name:'test_questions_mode_page',
        component: test_questions_mode
      }
    ]
    // meta:{
    //   requireAuth:true   //需要进行登录验证
    // }
  },
  {
    path:'/examine',
    name:'examinePage',
    component: ExaminePage,
    // meta:{
    //   requireAuth:true   //需要进行登录验证
    // }
  }

]

const router = new VueRouter({
  mode:"history",
  routes
})

//检查路由守卫的网页
// router.beforeEach(to,from,next) => {
//   if(to.matched.some(record => record.meta.requireAuth)){
//     //检查Token是否存在且有效
//     if(!store.getters['']){}
//   }
// }

export default router
